<?php
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('exercise.stylesheet');
$canDo = ExercisesHelper::getActions();
$user = JFactory::getUser();
$userId = $user->get('id');
?>
<script type="text/javascript">
    Joomla.submitbutton = function(task)
    {
        if (task == 'question.cancel' || document.formvalidator.isValid(document.id('question-form'))) {
            Joomla.submitform(task, document.getElementById('question-form'));
        }
    }
</script>

<form action="<?php echo JRoute::_('index.php?option=com_exercises&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="question-form" class="form-validate">
    <?php echo JLayoutHelper::render('joomla.edit.title_alias', $this); ?>
    <div class="form-horizontal">
        <?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?>

        <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', JText::_('COM_EXERCISES_QUESTION_DETAILS', true)); ?>
        <div class="row-fluid">
            <div class="span9">
                <?php echo $this->form->getControlGroup('exer_id'); ?>
                <?php echo $this->form->getControlGroup('question'); ?>                
            </div>
            <div class="span3">
                <?php echo JLayoutHelper::render('joomla.edit.global', $this); ?>
            </div>
        </div>
        <?php echo JHtml::_('bootstrap.endTab'); ?>
        <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'publishing', JText::_('JGLOBAL_FIELDSET_PUBLISHING', true)); ?>
        <div class="row-fluid form-horizontal-desktop">
            <div class="span6">
                <?php echo JLayoutHelper::render('joomla.edit.publishingdata', $this); ?>
            </div>
            <div class="span6">
                <?php echo $this->form->getControlGroups('metadata'); ?>
            </div>
        </div>
        <?php echo JHtml::_('bootstrap.endTab'); ?>

        <?php echo JHtml::_('bootstrap.endTabSet'); ?>
    </div>
    <input type="hidden" name="createdby" value="<?php echo $userId; ?>" />
    <input type="hidden" name="task" value="" />
    <?php echo JHtml::_('form.token'); ?>
</form>
